package homework;


import java.util.Arrays;
import java.util.Comparator;

public class TestRectangle {
    public static void main(String[] args) {
        Rectangle[] rectangles = new Rectangle[3];

        rectangles[0] = new Rectangle(8,2);
        rectangles[1] = new Rectangle(7,3);
        rectangles[2] = new Rectangle(6,4);

        for (Rectangle rectangle : rectangles) {
            System.out.println(rectangle.getInfo());
        }

        System.out.println("---------------------------------");
        Arrays.sort(rectangles, Comparator.comparingDouble(Rectangle::getLength));
        for (Rectangle rectangle : rectangles) {
            System.out.println(rectangle.getInfo());
        }

        System.out.println("---------------------------------");
        Arrays.sort(rectangles, Comparator.comparingDouble(Rectangle::area));
        for (Rectangle rectangle : rectangles) {
            System.out.println(rectangle.getInfo());
        }
    }
}
